package com.tvunetworks.center.user.service;

import com.tvunetworks.center.common.model.LoginUser;
import com.tvunetworks.center.common.util.Result;
import com.tvunetworks.center.user.model.RoleDevice;
import com.tvunetworks.center.user.model.RoleManagement;
import com.tvunetworks.center.user.model.param.AddRoleManagementParam;
import com.tvunetworks.center.user.model.param.PageRoleParam;
import com.tvunetworks.center.user.model.param.UpdateRoleManagementParam;
import com.tvunetworks.center.user.model.param.SearchRoleUserParam;
import com.tvunetworks.center.user.model.vo.RoleVo;
import com.tvunetworks.center.user.model.vo.SearchUserDeviceVo;

import java.util.List;
import java.util.Map;


/**
 * @author Etan Yang
 * @data: 2021/4/7 15:19
 * @program: tvucc-aggregator
 * @description:
 */

public interface RoleManagementService {
    /**
     * 添加role
     * @param loginUser loginUser
     * @param param param
     * @return Result
     */
    Result<Object> addRoleManagement(LoginUser loginUser, AddRoleManagementParam param);

    /**
     * 分页查询指定用户的role
     * @param userId userId
     * @param param param
     * @return Result
     */
    Result<Object> pageRole(String userId, PageRoleParam param);

    /**
     * 根据userId修改role
     * @param loginUser loginUser
     * @param param param
     * @return Result
     */
    Result<Object> updateRole(LoginUser loginUser, UpdateRoleManagementParam param);

    /**
     * 根据roleId删除role
     * @param loginUser loginUser
     * @param roleId roleId
     * @return Result
     */
    Result<Object> deleteRole(LoginUser loginUser, String roleId);

    /**
     * 分页查询该用户下的roleName
     * @param userId userId
     * @param param param
     * @return Result
     */
    Result<Object> pageRoleName(String userId, PageRoleParam param);

    /**
     * 通过roleId和userId获取该role的各种信息
     * @param roleId roleId
     * @param userId userId
     * @return RoleVo
     */
    RoleVo getRoleByRoleId(String roleId, String userId);

    /**
     * 根据主键获取Role
     * @param roleId roleId
     * @return RoleManagement
     */
    RoleManagement getByRoleId(String roleId);

    /**
     * 根据userId删除所有的role
     * @param userId userId
     */
    void deleteByUserId(String userId);

    /**
     * 获取role的全部feature和device
     * @param loginUser loginUser
     * @param param param
     * @return Result
     */
    Result<Object> getRoleMessage(LoginUser loginUser, SearchRoleUserParam param);

    /**
     * 获取该用户下指定Role没有的device
     * @param userId userId
     * @param param param
     * @return List
     */
    List<SearchUserDeviceVo> getReceiverList(String userId, SearchRoleUserParam param);


    /**
     * 解除device在role_manage表中的绑定关系
     * @param userId userId
     * @param peerIds peerIds
     */
    void deleteByUserIdAndPeerId(String userId,List<String> peerIds);

    /**
     * 获取admin不存在，但是userRole中存在的receiver集合
     * @return 返回需要删除的roleDevice集合
     */
    Map<String, Map<RoleManagement, List<String>>> listDataFromManageRole();


    /**
     * 删除roleDevice中的脏数据并返回删除结果
     * @param userId 用户id
     * @return 返回删除后的RoleDevice
     */
    List<RoleDevice> deleteRoleDevice(String userId);
}
